package com.example.cms.Queues;


import java.time.LocalDateTime;

public class Queue {
    private Integer queueId;
    private Integer appointmentId;
    private Integer doctorId;
    private String doctorName;
    private String departmentName;
    private Integer queueNumber;
    private String patientName;
    private String queueStatus;
    private LocalDateTime enterTime;
    private LocalDateTime callTime;
    private LocalDateTime finishTime;
    private Integer waitingTime;
    private String roomNumber;
    private String notes;

    // 构造器
    public Queue() {
        this.enterTime = LocalDateTime.now();
        this.queueStatus = "WAITING";
    }

    public Queue(Integer appointmentId, Integer doctorId, Integer queueNumber) {
        this();
        this.appointmentId = appointmentId;
        this.doctorId = doctorId;
        this.queueNumber = queueNumber;
    }

    // Getter 和 Setter 方法
    public Integer getQueueId() {
        return queueId;
    }

    public void setQueueId(Integer queueId) {
        this.queueId = queueId;
    }

    public Integer getAppointmentId() {
        return appointmentId;
    }

    public void setAppointmentId(Integer appointmentId) {
        this.appointmentId = appointmentId;
    }

    public Integer getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(Integer doctorId) {
        this.doctorId = doctorId;
    }

    public String getDoctorName() {
        return doctorName;
    }

    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public Integer getQueueNumber() {
        return queueNumber;
    }

    public void setQueueNumber(Integer queueNumber) {
        this.queueNumber = queueNumber;
    }

    public String getPatientName() {
        return patientName;
    }

    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }

    public String getQueueStatus() {
        return queueStatus;
    }

    public void setQueueStatus(String queueStatus) {
        this.queueStatus = queueStatus;
        if ("CALLED".equals(queueStatus)) {
            this.callTime = LocalDateTime.now();
        } else if ("FINISHED".equals(queueStatus)) {
            this.finishTime = LocalDateTime.now();
        }
    }

    public LocalDateTime getEnterTime() {
        return enterTime;
    }

    public void setEnterTime(LocalDateTime enterTime) {
        this.enterTime = enterTime;
    }

    public LocalDateTime getCallTime() {
        return callTime;
    }

    public void setCallTime(LocalDateTime callTime) {
        this.callTime = callTime;
    }

    public LocalDateTime getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(LocalDateTime finishTime) {
        this.finishTime = finishTime;
    }

    public Integer getWaitingTime() {
        return waitingTime;
    }

    public void setWaitingTime(Integer waitingTime) {
        this.waitingTime = waitingTime;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(String roomNumber) {
        this.roomNumber = roomNumber;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public void calculateWaitingTime() {
        if (this.callTime != null && this.enterTime != null) {
            this.waitingTime = (int) java.time.Duration.between(this.enterTime, this.callTime).toMinutes();
        }
    }

    @Override
    public String toString() {
        return "Queue{" +
                "queueId=" + queueId +
                ", queueNumber=" + queueNumber +
                ", patientName='" + patientName + '\'' +
                ", doctorName='" + doctorName + '\'' +
                ", queueStatus='" + queueStatus + '\'' +
                ", waitingTime=" + waitingTime +
                '}';
    }
}